from openai import OpenAI 
import os
from dotenv import load_dotenv
load_dotenv('.env.local')
client = OpenAI(
    api_key=os.getenv('DEEPSEEK_API_KEY'),
    base_url='https://api.deepseek.com/v1'
)

# # Round 1
# messages = [{"role": "user", "content": "世界上最高的山是哪座？"}]
# response = client.chat.completions.create(
#     model="deepseek-reasoner",
#     messages=messages
# )

# messages.append(response.choices[0].message)
# print(f"第一轮对话: {response.choices[0].message.content}")

# # Round 2
# messages.append({"role": "user", "content": "我刚刚问了你什么问题?"})
# response = client.chat.completions.create(
#     model="deepseek-reasoner",
#     messages=messages
# )

# messages.append(response.choices[0].message)
# print(f"第二轮对话: {response.choices[0].message.content}")

# messages=[]
# response = client.chat.completions.create(
#     model = "deepseek-reasoner",
#     messages=[
#         {'role':'system','content':'你是一个数学老师，请你回答今年高考数学相关问题'},
#         {'role':'user','content':'客观评价今年高考数学的难度如何？'},
#     ]
# ) 

# print('第一轮思考过程')
# print(response.choices[0].message.reasoning_content)
# print('第一轮回答')
# print(response.choices[0].message.content)







def seed_message(message):
    response = client.chat.completions.create(
        model='deepseek-reasoner',
        messages=message,
    )
    return response

if __name__ == '__main__':
    messages = []
    while 1 :
        question = input('请输入问题：')
        if question == 'exit':
            break
        messages.append({'role': 'user', 'content': question})
        response = seed_message(messages)
        message = response.choices[0].message
        messages.append(
            {
                'role': message.role,
                'content': message.content
            }
        )
        print('思考过程：')
        print(message.reasoning_content)
        print('回答：')
        print(message.content)














# from openai import OpenAI
# import os
# from dotenv import load_dotenv
# load_dotenv('.env.local')


# client = OpenAI(
#   api_key=os.getenv('DEEPSEEK_API_KEY'),
#   base_url="https://api.deepseek.com/v1",
# )

# completion = client.chat.completions.create(
#   model='deepseek-reasoner',
#   messages=[
#     {'role': 'system', 'content': '你是一个足球领域的专家，请尽量帮我回答与足球相关的问题。'},
#     {'role': 'user', 'content': 'c罗是哪个国家的足球运动员？'},
#   ]
# )

# print('思考过程：')
# print(completion.choices[0].message.reasoning_content)

# print('最终答案：')
# print(completion.choices[0].message.content)